import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;


public class TestLesson018{
	public static void main(String args[]) throws SQLException, ClassNotFoundException 
 {

		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dayuanit001", "root", "123456");
		String sql = "select * from d_user;";

		List<User> list = new ArrayList<User>();

		Statement sm = conn.createStatement();
		ResultSet rs = sm.executeQuery(sql);

		User us = null;
		while(rs.next()) {
			int id = rs.getInt(1);
			String username = rs.getString(2);
			int countryId = rs.getInt(3);
			int amount = rs.getInt(4);

			us = new User();
			us.id = id;
			us.username = username;
			us.countryId = countryId;
			us.amount = amount;
			list.add(us);
		}

		for (User user : list) {
			System.out.println(user.id + " " + user.username + " " + user.countryId + " " + user.amount);
		}


	}
}